/*Stata Syntax for Something old, something new, something borrowed,
something true?  comment on Lister's 'Institutions, Inequality and
Social Norms: Explaining Variations in Participation' (Arzheimer
2007*/


	/*Replication/alternative analyses/graphs/LaTeX tables*/
	use turnout,replace
	
	/*PCSE Model / bootstrap*/
	xtpcse logitvturn compvote singmemd fed pres strb rgdpc ineq vturnlag
	est store PCSE
	bootstrap ,seed(123456) rep(200): reg logitvturn compvote singmemd fed pres strb rgdpc ineq vturnlag
	est store Bootstrap
	estout PCSE Bootstrap using tabelle-2-body.tex, cells(b(star fmt(%9.3f)) t(par) ) stats(r2 N, fmt(%9.3f %9.0g) labels("$ R^{2}$" "$ n$"))  varlabels(fed FED pres PRES strbic STRBIC rgdpc RGDPC vturnlag VTURNLAG compvote COMPVOTE singmemd SINGMEMD vturnlag VTURNLAG ineq INEQ _cons Constant)  mlabels(,none) collabels(,none) style(tex) replace




	graph twoway scatter ineq year if nonmiss,by(cntry,note("")) ytitle("inequality") subtitle(, nobexpand nobox bcolor(none))
	graph export ineqtime.eps,replace

	graph twoway scatter vturn year if nonmiss,by(cntry,note("")) ytitle("turnout") subtitle(, nobexpand nobox bcolor(none)) yscale(range(40 100))
	graph export turnouttime.eps,replace



	reg logitvturn compvote singmemd fed pres strb rgdpc ineq vturnlag if nonmiss
	dfbeta

	gen bcountryvar =.
	lab var bcountryvar "Variation of _b[ineq] if countries are excluded"


	
	forvalues c= 1/15 {
		reg logitvturn compvote singmemd fed pres strb rgdpc ineq vturnlag if country ~=`c'
		replace bcountryvar = _b[ineq] if _n == `c'
		}

	gen byearvar =.
	lab var byearvar "Variation of _b[ineq] if years are excluded"
	
	forvalues y= 1963/1993 {
		qui		reg logitvturn compvote singmemd fed pres strb rgdpc ineq vturnlag if year ~=`y'
		replace byearvar = _b[ineq] if _n == `y' -1962
		}

	
	list DFine if DFineq >2/sqrt(129)
	/*geht nur nach reg...*/

	
	
	graph twoway (scatter vturn ineq)  (lfit vturn ineq)  if nonmiss,by(cntry,note("") legend(off)) xtitle("inequality") ytitle("turnout") subtitle(, nobexpand nobox bcolor(none)) yscale(range(40 100))
	
	graph export turnoutineq.eps, replace



	gen countryslope=.
		forvalues c= 1/15 {
		reg logitvturn  ineq if nonmiss & country ==`c'
		replace  countryslope=_b[ineq] if _n == `c'
		}


	/*Kludge to get rho out*/
	capture program drop dummy
   program dummy,eclass
	ereturn scalar rho = `e(rho)'
	end
	

	preserve
	drop if cntry=="FRA"
	drop if cntry=="FRG" & year==1990

	desmat cntry

	xtpcse logitvturn ineq rgdpc vturnlag  _x* if nonmiss
	est store finale1

	xtpcse logitvturn ineq rgdpc vturnlag  _x* if nonmiss ,correlation(ar1) 
	dummy
	est store finale2

	xtpcse logitvturn ineq rgdpc  _x* if nonmiss
	est store finale3

	xtpcse logitvturn ineq rgdpc  _x* if nonmiss,correlation(ar1) 
	dummy
	est store finale4


	xtpcse vturn ineq rgdpc vturnlag  _x* if nonmiss
	est store finale5

	xtpcse vturn ineq rgdpc vturnlag  _x* if nonmiss ,correlation(ar1) 
	dummy
	est store finale6

	xtpcse vturn ineq rgdpc  _x* if nonmiss
	est store finale7

	xtpcse vturn ineq rgdpc  _x* if nonmiss,correlation(ar1) 
	dummy
	est store finale8


	/*Comparison*/
	
	
	
		estout finale1 finale2 finale3 finale4 finale5 finale6 finale7 finale8 using tabelle-3-body.tex, cells(b(star fmt(%9.3f)) t(par) ) stats(rho r2 N, fmt(%9.3f %9.3f %9.0g) labels($\rho$ "$ R^{2}$" "$ n$"))   varlabels(ineq INEQ rgdpc RGDPC _cons Constant _x_1 AUS _x_2 BEL _x_3 CAN _x_4 DEN _x_5 FIN _x_6 FRG _x_7 IRE _x_8 ITA _x_9 JPN _x_10 NET _x_11 SWE _x_12 UK _x_13 USA)  mlabels(,none) collabels(,none) style(tex) replace
